/*
 * Copyright (C) 2005-present, 58.com.  All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.swak.paxos.breakpoint;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.swak.paxos.protocol.PaxosMessage;

/**
 * instance相关断点跟踪
 */
public class InstanceBP {

	private static final Logger logger = LoggerFactory.getLogger(InstanceBP.class);

	public static void commitTimeout(long timeoutMs, int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP commitTimeout timeoutMs {}, group : {}, instanceID {}.", timeoutMs, groupId,
				instanceID);
	}

	public static void newInstance(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP newInstance, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void sendMessage(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP sendMessage, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void broadcastMessage(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP broadcastMessage, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onNewValueCommitTimeout(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onNewValueCommitTimeout, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onReceive(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceive, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onReceiveParseError(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceiveParseError, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onReceivePaxosMsg(int groupId, long instanceID, PaxosMessage message) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceivePaxosMsg, group : {}, instanceID {}, fromNode {}, PaxosMessage {}.", groupId,
				instanceID, message.getNodeID(), message);
	}

	public static void onReceivePaxosMsgNodeIDNotValid(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceivePaxosMsgNodeIDNotValid, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onReceivePaxosMsgTypeNotValid(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceivePaxosMsgTypeNotValid, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onReceivePaxosProposerMsgInotsame(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceivePaxosProposerMsgInotsame, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onReceivePaxosAcceptorMsgInotsame(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceivePaxosAcceptorMsgInotsame, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onReceivePaxosAcceptorMsgAddRetry(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onReceivePaxosAcceptorMsgAddRetry, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onInstanceLearned(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onInstanceLearned, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onInstanceLearnedNotMyCommit(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onInstanceLearnedNotMyCommit, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onInstanceLearnedIsMyCommit(int useTimeMs, int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onInstanceLearnedIsMyCommit useTimeMs {}, group : {}, instanceID {}.", useTimeMs,
				groupId, instanceID);
	}

	public static void onInstanceLearnedSMExecuteFail(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP onInstanceLearnedSMExecuteFail, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void checksumLogicFail(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("InstanceBP checksumLogicFail, group : {}, instanceID {}.", groupId, instanceID);
	}

}
